#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include<QWebSocketServer>
#include<QTcpServer>
#include<QHttpServer>
#include<QMap>
#include<QMutex>
#include<TcpServer.h>
extern QMutex * m_mutex;//锁webSocketM变量，保证只有一个线程可以访问该变量
extern QMap<QWebSocket*,int> webSocketM;

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void newClient();
    void recvmeg(QString s);
    void sendMsg();
    void disWebSocket(QWebSocket* webSocket);
private slots:
    void on_pushButton_clicked();

    void on_listenButton_clicked();

private:
    Ui::MainWindow *ui;
    QWebSocketServer* webSocketServer;//websocket通信
    QTcpServer* tcpServer;//tcpserver通信
    QHttpServer* httpServer;//httpserver通信
    QWebSocket* tcpClient;//tcp客户端
    QWebSocket* httpClient;//http客户端
signals:
    void sendC(QString s,SendContent t);//连接状态

};
#endif // MAINWINDOW_H
